package com.chagee.store.operation.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 结算单支付方式
 *
 * @Author : hk
 * @Date : 2025/4/25
 */

@Getter
@AllArgsConstructor
public enum PayTypeEnum {

	ONLINE("ONLINE", "线上"),

	OFFLINE("OFFLINE", "线下"),

	;

	private final String type;
	private final String desc;


	public static PayTypeEnum queryByType(String type) {
		for (PayTypeEnum value : values()) {
			if (Objects.equals(type, value.getType())) {
				return value;
			}
		}
		return null;
	}

	public static PayTypeEnum of(String type) {
		return Stream.of(PayTypeEnum.values()).filter(v -> v.type.equalsIgnoreCase(type)).findFirst().orElse(null);
	}
}
